<template>
  <!-- 选择企微号 -->
  <el-dialog title="选择企微号" :visible.sync="visible" @close="handleCloseDialog" :close-on-click-modal="false"
    :close-on-press-escape="false" append-to-body width="660px" top="8vh!important" class="dialog_nopadd">
    <div class="config-tips">
      <el-alert
        type="warning"
        show-icon>
        <div slot="title" style="font-size: 14px;line-height: 22px;color: rgba(0,0,0,.85);">
          应用会将多号聚合模式该功能的所有配置新增/覆盖至选中企微号该功能的配置，请谨慎操作。
        </div>
      </el-alert>
    </div>
    <div class="content-big">
      <div class="c_warrper_left">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" class="p-12">
          <el-form-item label="" prop="keyword" class="mb-0">
            <el-input placeholder="请输入关键词" v-model="queryParams.keyword" @keyup.enter.native="handleQuery"
              class="x-input-select" style="width: 180px">
              <el-button slot="append" icon="el-icon-search"></el-button>
            </el-input>
          </el-form-item>
          <el-form-item prop="userName2" class="mb-0">
            <el-select v-model="queryParams.userName6" @change="handleQuery" placeholder="全部分组" style="width: 120px">
              <el-option v-for="item in groupList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="userName2" class="mb-0">
            <el-select v-model="queryParams.userName7" @change="handleQuery" placeholder="在线状态" style="width: 100px">
              <el-option v-for="item in labelList" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div class="flex">
          <div class="content-left">
            <div class="table-big">
              <el-button type="primary" size="small" plain style="">全选所有</el-button>
              <el-table :data="tableDataList" ref="companylabelList" @selection-change="handleSelectionChange" max-height="600">
                <el-table-column type="selection" width="60" align="center" />
                <el-table-column :label="item.label" :align="item.align ? item.align : ``"
                  v-for="(item, index) in tableColumns" :key="index" :prop="item.key"
                  :min-width="item.minWidth ? item.minWidth : ``" :fixed="item.fixed ? item.fixed : false"
                  :show-overflow-tooltip="true">
                  <!--用于表格自定义-->
                  <template slot-scope="scope">
                    <div v-if="item.key == 'name'">
                      <div class="userInfo">
                        <img src="@/assets/images/profile.jpg" />
                        <div class="user-big">
                          <div class="name">群聊</div>
                          <div class="label">成员<span>3</span></div>
                        </div>
                      </div>
                    </div>
                    <div v-else style="margin-right: 20px">
                      {{ scope.row[item.key] }}
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <div class="content-center">
            <div class="title plr-12 flexbetween">
              <span class="c_text2 fw-6">已选择 <span class="c_text3 fw-0">（3）</span></span>
              <span class="c_primary commhover">清空</span>
            </div>
            <ul class="user-list p-12">
              <li v-for="item in 20" :key="item" class="p-8 flexbetween">
                <span>肖洁</span><i class="el-icon-delete commhover"></i>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>

    <div class="footer-btn" slot="footer">
      <el-button @click="handleCloseDialog">取消</el-button>
      <el-button type="primary">提交</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { listUser } from "@/api/system/user";

export default {
  name: "checkCompanyAccount",
  data() {
    return {
      // 查询参数
      input3: null, //群查找
      radio: null, //
      labelList: [
        //称呼
        { id: 1, name: "在线" },
        { id: 2, name: "离线" },
      ],
      groupList: [
        //群查找
        { id: 1, name: "含任意关键词" },
        { id: 2, name: "含所有关键词" },
      ],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName1: null,
        userName2: null,
      },
      tableColumns: [
        {
          key: "name",
          label: `选择本页`,
          visible: true,
          minWidth: 200,
          fixed: true,
        },
        {
          key: "status",
          label: ``,
          visible: true,
          minWidth: 150,
          fixed: true,
          align: "right",
        },
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
      multipleSelection: [], //表格多选
      showSelectSmartTags: false, //智能标签
      tableHeight: 600,
      dateRange1: [],
    };
  },
  created() {
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: "小红",
        status: "离线",
      };
      this.tableDataList.push(obj);
    }
  },
  props: ['visible'],
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          this.userList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 表单重置
    reset() {
      this.form = {
        userId: undefined,
        deptId: undefined,
        userName: undefined,
        nickName: undefined,
        password: undefined,
        phonenumber: undefined,
        email: undefined,
        sex: undefined,
        status: "0",
        remark: undefined,
        postIds: [],
        roleIds: [],
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.multipleSelection = selection.map((item) => item.id);
      //   this.single = selection.length != 1;
      //   this.multiple = !selection.length;
    },
    handleCloseDialog() {
      this.$emit('handCloseDialog');
      // this.$emit("handleQuery");
    },
  },
};
</script>

<style scoped lang="scss">
.c_warrper_left {
  flex: 1 1;
}
.footer-btn {
  position: relative;
}

.table-big {
  position: relative;

  .el-button {
    position: absolute;
    right: 10px;
    z-index: 9;
    margin-top: 6px;
  }
}

.userInfo {
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  padding-left: 50px;
  font-size: 14px;
  list-style: none;
  text-align: left;
  display: flex;
  align-items: center;
  justify-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    left: 0px;
    top: 0px;
    position: absolute;
  }

  .label {
    margin-top: 2px;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .groupInfo {
    background-color: rgb(48, 112, 255);
    align-self: flex-start;
    width: 40px;
    padding: 2px 7px;
    display: inline-block;
    color: #fff;
    border-radius: 5px;
    margin-top: 10px;
    margin-left: 10px;
  }

  .user-big {
    display: flex;
    flex-direction: column;
    line-height: 18px;
  }
}

.content-big {
  display: flex;
  height: 100%;

  .content-left {
    flex: 1 1;
    border-right: 1px solid #eee;
  }

  .content-center {
    width: 200px;

    .title {
      background-color: #fafafa !important;
      border-bottom: 1px solid #e9e9e9;
      height: 44px;
    }

    .user-list {
      max-height: 558px;
      overflow-y: auto;

      li {
        &:hover {
          background-color: #eff3ff;
        }
      }
    }
  }
}

::v-deep .el-dialog__body {
  height: 660px;
}

.el-checkbox-group {
  margin-top: 20px;

  .el-checkbox {
    margin-bottom: 12px;
    width: 150px;
  }
}

.mypagination {
  padding: 0 !important;
  padding-bottom: 30px !important;
}

.el-table {
  ::v-deep .el-table__header th {
    background-color: #fafafa !important;
    border-bottom: 1px solid #e9e9e9 !important;
  }
}

.plantitle {
  background-color: #f0f0f0;
}
</style>
